import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import * as path from 'path'; 

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  base: '/',
  resolve: {
    alias: {
      '@': path.resolve(process.cwd(), 'src'), // 使用 process.cwd() 以确保路径正确
    },
  },
  server: {
    host: '0.0.0.0',
    proxy: {
      '/api': {
        target: 'https://music.163.com/',  
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
      '/vvhan': {
        target: 'https://api.vvhan.com/api/',  
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/vvhan/, ''),
      },
    },
  },
});
